using UnityEngine;
using System.Collections;

public class Phantom : MonoBehaviour {
	
	//public Transform player;
	public float vel;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () 
	{
	     if(Player.player != null)
		 {
	        PhantomMoviment(transform, Player.player.transform, vel);
		 }
	}


    public void PhantomMoviment(Transform phantom, Transform player, float vel)
    {
		if(player != null)
		{
		 vel *= Time.deltaTime;
	     if(player.position.x > phantom.position.x)
		 {
			phantom.Translate(vel,0,0);
		 }
		 
		 else
		 {
			phantom.Translate(-vel,0,0);
		 }
		
		 if(player.position.y < phantom.position.y)
		 {
			phantom.Translate(0,-vel,0);
		 }
		 
		 else
		 {
		   	phantom.Translate(0,vel,0);
		 }
		}
    }

}